-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrating class symbol support #16
Integrating class symbol support #16
Conversation
a4f8b8b
to
77494c4
Compare
@SeeminglyScience with the integration pretty much all the changes you had to make to the unit tests I reverted. Can you explain if any of those were intentional (beyond just "making them pass")? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My own questions for you both.
src/PowerShellEditorServices/Services/Symbols/ReferenceTable.cs
Outdated
Show resolved
Hide resolved
src/PowerShellEditorServices/Services/Symbols/ReferenceTable.cs
Outdated
Show resolved
Hide resolved
src/PowerShellEditorServices/Services/Symbols/ReferenceTable.cs
Outdated
Show resolved
Hide resolved
src/PowerShellEditorServices/Services/Symbols/SymbolsService.cs
Outdated
Show resolved
Hide resolved
src/PowerShellEditorServices/Services/Symbols/SymbolsService.cs
Outdated
Show resolved
Hide resolved
test/PowerShellEditorServices.Test/Language/SymbolsServiceTests.cs
Outdated
Show resolved
Hide resolved
test/PowerShellEditorServices.Test/Language/SymbolsServiceTests.cs
Outdated
Show resolved
Hide resolved
test/PowerShellEditorServices.Test/Language/SymbolsServiceTests.cs
Outdated
Show resolved
Hide resolved
test/PowerShellEditorServices.Test.Shared/References/FunctionReference.ps1
Show resolved
Hide resolved
Hm ok so the sorting isn't quite right. Debugging |
261360c
to
70bcd04
Compare
Currently shows variable-assignments for every parameter and re-assignments inside functions/methods in outline + workspace search. Feels messy compared to stable. Maybe stick with current behavior for now? If so, it might require either of these:
|
test/PowerShellEditorServices.Test/Language/SymbolsServiceTests.cs
Outdated
Show resolved
Hide resolved
if (file.References.TryGetReferences(foundSymbol.SymbolName, out ConcurrentBag<SymbolReference> references)) | ||
{ | ||
return references; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (file.References.TryGetReferences(foundSymbol.SymbolName, out ConcurrentBag<SymbolReference> references)) | |
{ | |
return references; | |
} | |
if (file.References.TryGetReferences(foundSymbol.SymbolName, out ConcurrentBag<SymbolReference> references)) | |
{ | |
return references.Where((r) => | |
foundSymbol.SymbolType == r.SymbolType || | |
(foundSymbol.SymbolType is SymbolType.Class or SymbolType.Enum or SymbolType.Type | |
&& r.SymbolType is SymbolType.Class or SymbolType.Enum or SymbolType.Type) | |
); | |
} |
Filter on symbol type. Will currently match ex. a function and enum/class/type with same name.
Same, that's what I was thinking. |
82ec11f
to
604d6a7
Compare
return AstVisitAction.Continue; | ||
} | ||
|
||
public override AstVisitAction VisitInvokeMemberExpression(InvokeMemberExpressionAst methodCallAst) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which scenario is this for? I don't think you'll be able to match it to the correct method to count it as a reference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So it turns out it works quite well! By bucketing all the overloads (of the same name) together, and returning a set of possible definitions, VS Code just does what it needs so you can do:
class SuperClass : BaseClass {
[string]MyClassMethod([string]$param1, $param2, [int]$param3) {
$this.SomePropWithDefault = 'something happend'
$param1
return 'finished'
}
[string]
MyClassMethod([MyEnum]$param1) {
return 'hello world'
}
[string]MyClassMethod() {
return 'hello world'
}
}
$o = [SuperClass]::new()
$o.MyClassMethod()
and find definition on MyClassMethod()
shows the three potential matches:
No, it's not perfect, but it's a whole lot better than nothing!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, go to definition makes sense. 👍 You could also filter on argument count, but argument types won't work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make it complete, should ::new()
return the constructors? Because that's a reserved method when static (InvokeMemberExpressionAst.Static == true
), right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good idea!
Bumps [Microsoft.PowerShell.SDK](https://github.com/PowerShell/PowerShell) from 7.3.1 to 7.3.2. - [Release notes](https://github.com/PowerShell/PowerShell/releases) - [Commits](PowerShell/PowerShell@v7.3.1...v7.3.2) --- updated-dependencies: - dependency-name: Microsoft.PowerShell.SDK dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Name was wrong.
To actually be an inclusive check of the given point being between the two boundary points.
Space between name and subsequent parenthesis.
Let it be known that Patrick bets $500 that no one notices this. And to be fair, searching the whole workspace now works great.
And delete "find details" for non-commands (as they all get their display strings set on creation now).
The visitor exists but it's not called, probably a module-import issue.
be3e601
to
6d8b0ba
Compare
Co-authored-by: Patrick Meinecke <[email protected]>
So that we rely on the dictionary to sort our symbols into the equivalent types instead of having to perform a filter.
I think there's a cleaner way to do this, but this works.
Against the full name and not just the identifier, since it's what's displayed in the search menu. Now you can search methods by their parameters' names.
Should have been just `IndexOf`, and also use `+` instead of `string.Concat()` for simplicity and speed.
WIP: Attempting to integrate PowerShell#1886 with the changes previously made in PowerShell#1917.